layui.define(['layer'], function(exports) {
    "use strict";
    let validation = {
        init: function(title,verify,value) {
            let arr = verify.split("|");
            let message = "";
            for(let i in arr){
                message = validation.verify(arr[i],value);
                if(message.trim().length > 0 && message!=undefined){
                    message = title+":"+message;
                    layer.msg(message,{icon:7,offset:'10px'})
                    return false
                    break;
                }
            }
            return true;
        },
        verify: function(verify,val){
            switch(verify) {
                case 'required':
                    return (val.length<1 || val=='null' || val==null || val==undefined)?'不能为空!':'';
                case 'islng':
                    let lng = /^(\-|\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,6})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,6}|180)$/;
                    return !lng.test(val)?'经度整数部分为0-180,小数部分为0到6位!':'';
                case 'islat':
                    let lat = /^(\-|\+)?([0-8]?\d{1}\.\d{0,6}|90\.0{0,6}|[0-8]?\d{1}|90)$/;
                    return !lat.test(val)?'纬度整数部分为0-90,小数部分为0到6位!':'';
                default:
                    return '';
            }
        }
    };
    exports('validation', validation);
});